TryFindLastWhere Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Finds the last item in a collection that satisfies the condition defined by predicate.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static bool TryFindLastWhere<T>(
	IEnumerable<T> collection,
	Predicate<T> predicate,
	out T foundItem
)
Visual Basic (Declaration)
Public Shared Function TryFindLastWhere(Of T) ( _
	collection As IEnumerable(Of T), _
	predicate As Predicate(Of T), _
	<OutAttribute> ByRef foundItem As T _
) As Boolean
Visual C++
public:
generic<typename T>
static bool TryFindLastWhere (
	IEnumerable<T>^ collection, 
	Predicate<T>^ predicate, 
	[OutAttribute] T% foundItem
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection to search.
predicate
Predicate<(Of <T>)>
A delegate that defined the condition to check for.
foundItem
T%
Outputs the last item in the collection that matches the condition, if the method returns true.

Return Value

True if an item satisfying the condition was found. False if no such item exists in the collection.

Type Parameters

T

Remarks

If the collection implements IList<T>, then the list is scanned in reverse until a matching item is found. Otherwise, the entire collection is iterated in the forward direction.

See Also